package apiday08.reflect;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class ReflectDemo3 {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
        Class cls = Class.forName("apiday08.reflect.Person");
        Constructor c = cls.getConstructor(String.class);
        Object obj = c.newInstance("王五");
        System.out.println(obj);

        Constructor c2 = cls.getConstructor(String.class,int.class);
        Object obj2 = c2.newInstance("王五",45);
        System.out.println(obj2);

    }
}
